<?php
/**
 * 
 *
 * @author Iain Edminster
 */
class Bliss_DataReport_Result_Row implements Iterator, Countable
{
	protected $_items = array();

	public function __construct(array $items)
	{
		foreach($items as $key => $column) {
			$item = new Bliss_DataReport_Result_Item($key, $column['value']);
			if(isset($column['format']))	$item->setFormat($column['format']);
			if(isset($column['visible']))	$item->setVisible($column['visible']);

			$this->_items[$key]	= $item;
			unset($item);
		}
	}

	public function __get($key)
	{
		return $this->_items[$key];
	}

	public function  __isset($name)
	{
		return isset($this->_items[$name]);
	}

	public function count()
	{
		return count($this->_items);
	}

	public function rewind()
	{
		reset($this->_items);
	}

	public function current()
	{
		return current($this->_items);
	}

	public function key()
	{
		return key($this->_items);
	}

	public function next()
	{
		return next($this->_items);
	}

	public function valid()
	{
		return ($this->current() !== false);
	}
}
?>